import api from '@/common/api/login';
import nativeAction from '@/common/native';
/**
 * 登录请求服务器接口
 * @module login/login
 * @author dym
 */
export default {
  /**
   * @example 参数
   * @returns {Object} 登录接口
   */
  login (user, that) {
    let submitobj = {
      username: user.username,
      password: user.password,
      regId: '123',
      osType: '456'
    };
    nativeAction.getPushRegId(submitobj);
    api.login(submitobj).then(res => {
      that.setPermission(res.permission);
      that.setStore(res.org);
      //设置登录信息
      nativeAction.setInfo(res.user);
      if (res.org.groupCode) {
        if (res.user.bizCounts && res.user.bizCounts === 1) {
          that.$router.push('/home/card');
        }
        if (res.user.bizCounts && res.user.bizCounts > 1) {
          that.$router.push('/selectCompany');
        }
      } else {
        //that.$router.push('/selectCompany');
        that.$router.push('/bindingShop');
      }
    });
  }
};
